package ru.jexp.rcp.supply;

import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.application.ActionBarAdvisor;
import org.eclipse.ui.application.IActionBarConfigurer;
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
import org.eclipse.ui.application.WorkbenchWindowAdvisor;

import ru.jexp.rcp.supply.mui.JExpSupplyMessages;

public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {

    public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
        super(configurer);
    }

    public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer) {
        return new ApplicationActionBarAdvisor(configurer);
    }
    
    public void preWindowOpen() {
        getWindowConfigurer().setShowCoolBar(true);
        getWindowConfigurer().setShowStatusLine(true);
        getWindowConfigurer().setShowProgressIndicator(true);
        getWindowConfigurer().setTitle(JExpSupplyMessages.Application_title);
        getWindowConfigurer().setInitialSize(getScreen());
    }
    
    @Override
    public void postWindowCreate()
    {
    	//new JExpClientUpdater(Activator.getDefault()).update();
    }
    
	private Point getScreen() {
		int height = Display.getCurrent().getBounds().height;
		int width =  Display.getCurrent().getBounds().width;
		int x = Display.getCurrent().getBounds().x;
		int y = Display.getCurrent().getBounds().y;
		return new Point(x + width, y + height);
	}
}
